//#define IMAGE_NUM_OF_FILT_ELEMENTS 3 // load from GLES20Renderer
//#define IMAGE_WIDTH 640
//#define IMAGE_HEIGHT 696
precision mediump float;

const float c_fStepSizeX = 1.0 / float(IMAGE_WIDTH); // calculate pixel width
const float c_fStepSizeY = 1.0 / float(IMAGE_HEIGHT); // calculate pixel height

uniform float fTexSelWeight[IMAGE_NUM_OF_FILT_ELEMENTS]; // selector and weight of texel
uniform sampler2D s_baseMap;

varying vec2 v_texB; // texture coordinate

void main()
{
	vec2 v_pos; // calculate x and y position
	vec4 v_fragColorResult; // output texel
	v_fragColorResult = vec4(0, 0, 0, 0);

	// remember: pos x, pos y, weight
	for(int i = 0; i < (IMAGE_NUM_OF_FILT_ELEMENTS/3); i++){
		v_pos = vec2(
			v_texB.x + (c_fStepSizeX * fTexSelWeight[(i * 3) + 0]), // x position
			v_texB.y + (c_fStepSizeY * fTexSelWeight[(i * 3) + 1])  // y position
		);
		v_fragColorResult += (fTexSelWeight[(i * 3) + 2] * texture2D(s_baseMap, v_pos)); // weight
	}
	
	gl_FragColor = v_fragColorResult; 
}
